

<!DOCTYPE html>
<!--[if IE 8]><html class="no-js lt-ie9" lang="en" > <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js" lang="en" > <!--<![endif]-->
<head>
  <meta charset="utf-8">
  
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  
  <title>第一章：数据结构和算法 &mdash; python3-cookbook 3.0.0 documentation</title>
  

  
  
  
  

  

  
  
    

  

  <link rel="stylesheet" href="../_static/css/theme.css" type="text/css" />
  <link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
    <link rel="index" title="Index" href="../genindex.html" />
    <link rel="search" title="Search" href="../search.html" />
    <link rel="next" title="1.1 解压序列赋值给多个变量" href="../c01/p01_unpack_sequence_into_separate_variables.html" />
    <link rel="prev" title="&lt;no title&gt;" href="../c03/k8s.html" /> 

  
  <script src="../_static/js/modernizr.min.js"></script>

</head>

<body class="wy-body-for-nav">

   
  <div class="wy-grid-for-nav">

    
    <nav data-toggle="wy-nav-shift" class="wy-nav-side">
      <div class="wy-side-scroll">
        <div class="wy-side-nav-search">
          

          
            <a href="../index.html" class="icon icon-home"> python3-cookbook
          

          
          </a>

          
            
            
              <div class="version">
                3.0
              </div>
            
          

          
<div role="search">
  <form id="rtd-search-form" class="wy-form" action="../search.html" method="get">
    <input type="text" name="q" placeholder="Search docs" />
    <input type="hidden" name="check_keywords" value="yes" />
    <input type="hidden" name="area" value="default" />
  </form>
</div>

          
        </div>

        <div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation">
          
            
            
              
            
            
              <ul class="current">
<li class="toctree-l1"><a class="reference internal" href="k8s.html">k8s 安装</a></li>
<li class="toctree-l1 current"><a class="current reference internal" href="#">第一章：数据结构和算法</a><ul>
<li class="toctree-l2"><a class="reference internal" href="../c01/p01_unpack_sequence_into_separate_variables.html">1.1 解压序列赋值给多个变量</a></li>
<li class="toctree-l2"><a class="reference internal" href="../c01/p02_unpack_elements_from_iterables.html">1.2 解压可迭代对象赋值给多个变量</a></li>
<li class="toctree-l2"><a class="reference internal" href="../c01/p03_keep_last_n_items.html">1.3 保留最后 N 个元素</a></li>
<li class="toctree-l2"><a class="reference internal" href="../c01/p04_find_largest_or_smallest_n_items.html">1.4 查找最大或最小的 N 个元素</a></li>
<li class="toctree-l2"><a class="reference internal" href="../c01/p05_implement_a_priority_queue.html">1.5 实现一个优先级队列</a></li>
<li class="toctree-l2"><a class="reference internal" href="../c01/p06_map_keys_to_multiple_values_in_dict.html">1.6 字典中的键映射多个值</a></li>
<li class="toctree-l2"><a class="reference internal" href="../c01/p07_keep_dict_in_order.html">1.7 字典排序</a></li>
<li class="toctree-l2"><a class="reference internal" href="../c01/p08_calculating_with_dict.html">1.8 字典的运算</a></li>
<li class="toctree-l2"><a class="reference internal" href="../c01/p09_find_commonalities_in_dicts.html">1.9 查找两字典的相同点</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="p02_strings_and_text.html">第二章：字符串和文本</a></li>
<li class="toctree-l1"><a class="reference internal" href="../aboutme.html">关于</a></li>
</ul>

            
          
        </div>
      </div>
    </nav>

    <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap">

      
      <nav class="wy-nav-top" aria-label="top navigation">
        
          <i data-toggle="wy-nav-top" class="fa fa-bars"></i>
          <a href="../index.html">python3-cookbook</a>
        
      </nav>


      <div class="wy-nav-content">
        
        <div class="rst-content">
        
          















<div role="navigation" aria-label="breadcrumbs navigation">

  <ul class="wy-breadcrumbs">
    
      <li><a href="../index.html">Docs</a> &raquo;</li>
        
      <li>第一章：数据结构和算法</li>
    
    
      <li class="wy-breadcrumbs-aside">
        
            
            <a href="../_sources/chapters/p01_data_structures_algorithms.rst.txt" rel="nofollow"> View page source</a>
          
        
      </li>
    
  </ul>

  
  <hr/>
</div>
          <div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
           <div itemprop="articleBody">
            
  <div class="section" id="id1">
<h1>第一章：数据结构和算法<a class="headerlink" href="#id1" title="Permalink to this headline">¶</a></h1>
<p>Python 提供了大量的内置数据结构，包括列表，集合以及字典。大多数情况下使用这些数据结构是很简单的。
但是，我们也会经常碰到到诸如查询，排序和过滤等等这些普遍存在的问题。
因此，这一章的目的就是讨论这些比较常见的问题和算法。
另外，我们也会给出在集合模块 <code class="docutils literal notranslate"><span class="pre">collections</span></code> 当中操作这些数据结构的方法。</p>
<div class="toctree-wrapper compound">
<ul>
<li class="toctree-l1"><a class="reference internal" href="../c01/p01_unpack_sequence_into_separate_variables.html">1.1 解压序列赋值给多个变量</a></li>
<li class="toctree-l1"><a class="reference internal" href="../c01/p02_unpack_elements_from_iterables.html">1.2 解压可迭代对象赋值给多个变量</a></li>
<li class="toctree-l1"><a class="reference internal" href="../c01/p03_keep_last_n_items.html">1.3 保留最后 N 个元素</a></li>
<li class="toctree-l1"><a class="reference internal" href="../c01/p04_find_largest_or_smallest_n_items.html">1.4 查找最大或最小的 N 个元素</a></li>
<li class="toctree-l1"><a class="reference internal" href="../c01/p05_implement_a_priority_queue.html">1.5 实现一个优先级队列</a></li>
<li class="toctree-l1"><a class="reference internal" href="../c01/p06_map_keys_to_multiple_values_in_dict.html">1.6 字典中的键映射多个值</a></li>
<li class="toctree-l1"><a class="reference internal" href="../c01/p07_keep_dict_in_order.html">1.7 字典排序</a></li>
<li class="toctree-l1"><a class="reference internal" href="../c01/p08_calculating_with_dict.html">1.8 字典的运算</a></li>
<li class="toctree-l1"><a class="reference internal" href="../c01/p09_find_commonalities_in_dicts.html">1.9 查找两字典的相同点</a></li>
</ul>
</div>
</div>


           </div>
           
          </div>
          <footer>
  
    <div class="rst-footer-buttons" role="navigation" aria-label="footer navigation">
      
        <a href="../c01/p01_unpack_sequence_into_separate_variables.html" class="btn btn-neutral float-right" title="1.1 解压序列赋值给多个变量" accesskey="n" rel="next">Next <span class="fa fa-arrow-circle-right"></span></a>
      
      
        <a href="../c03/k8s.html" class="btn btn-neutral" title="&lt;no title&gt;" accesskey="p" rel="prev"><span class="fa fa-arrow-circle-left"></span> Previous</a>
      
    </div>
  

  <hr/>

  <div role="contentinfo">
    <p>
        &copy; Copyright 2017, 熊能.

    </p>
  </div>
  Built with <a href="http://sphinx-doc.org/">Sphinx</a> using a <a href="https://github.com/rtfd/sphinx_rtd_theme">theme</a> provided by <a href="https://readthedocs.org">Read the Docs</a>. 

</footer>

        </div>
      </div>

    </section>

  </div>
  


  

    <script type="text/javascript">
        var DOCUMENTATION_OPTIONS = {
            URL_ROOT:'../',
            VERSION:'3.0.0',
            LANGUAGE:'None',
            COLLAPSE_INDEX:false,
            FILE_SUFFIX:'.html',
            HAS_SOURCE:  true,
            SOURCELINK_SUFFIX: '.txt'
        };
    </script>
      <script type="text/javascript" src="../_static/jquery.js"></script>
      <script type="text/javascript" src="../_static/underscore.js"></script>
      <script type="text/javascript" src="../_static/doctools.js"></script>

  

  <script type="text/javascript" src="../_static/js/theme.js"></script>

  <script type="text/javascript">
      jQuery(function () {
          SphinxRtdTheme.Navigation.enable(true);
      });
  </script> 

</body>
</html>